//
//  MyMessageController.m
//  大股票
//
//  Created by apple on 2019/9/5.
//  Copyright © 2019 apple. All rights reserved.
//

#import "MyMessageController.h"
#import "MessageTableViewCell.h"
#import "MyMessageDetailController.h"

@interface MyMessageController ()<UITableViewDelegate,UITableViewDataSource>
@property(copy,nonatomic)NSArray* array;
@end

@implementation MyMessageController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title=@"我的消息";
    [self settableview];
    self.array=[DGPUtil allApplyModel];
    if (@available(iOS 11.0, *)) {
        self.tableview.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
}

-(void)settableview{
    [self.tableview registerNib:[UINib nibWithNibName:@"MessageTableViewCell" bundle:nil] forCellReuseIdentifier:@"MessageTableViewCell"];
    self.tableview.rowHeight = 82;
    self.tableview.tableFooterView =[UIView new];
}

#pragma mark - UITableViewDataSource
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    MessageTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MessageTableViewCell" forIndexPath:indexPath];
    cell.applyModel=self.array[indexPath.row];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.array.count;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    MessageTableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    MyMessageDetailController* detail=[[MyMessageDetailController alloc] init];
    detail.applyModel=cell.applyModel;
    [self.navigationController pushViewController:detail animated:YES];
}
@end
